from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')

# 浏览器名称
print(driver.name)

# 当前url
print(driver.current_url)

# 页面源码
# print(driver.page_source)

# 当前窗口句柄
print(driver.current_window_handle)

print('-'*100)
# 当前浏览器所有标签句柄
driver.find_element(By.LINK_TEXT, '新闻').click()
print(driver.window_handles)

# 浏览器退出
time.sleep(2)
driver.quit()